import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:flutter/material.dart';

class ChartAccountItem extends StatelessWidget {
  final String name;
  final String title;
  final String amount;
  final String status;
  final VoidCallback onTap;
  final bool isChild;

  const ChartAccountItem(
      {Key key,
      this.name,
      this.onTap,
      this.title,
      this.status,
      this.amount,
      this.isChild = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PressedOpacityButton(
      onPressed: onTap,
      color: Colors.white,
      padding: EdgeInsets.only(
        left: isChild ? getDp(55) : getDp(35),
        top: getDp(15),
        right: getDp(35),
        bottom: getDp(15),
      ),
      border: Border(
        bottom: BorderSide(color: aceGrayColor, width: getDp(0.5)),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  name,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w400,
                    height: 14 / 16,
                  ),
                ),
                if (title != null)
                  Padding(
                    padding: const EdgeInsets.only(top: 10.0),
                    child: Row(
                      children: [
                        Text(
                          title,
                          style: TextStyle(
                            color: aceDarkGrayColor.withOpacity(0.7),
                            fontSize: getSp(16),
                            fontWeight: FontWeight.w400,
                            height: 14 / 16,
                          ),
                        ),
                        if (status != null)
                          Padding(
                            padding: EdgeInsets.only(left: getDp(10)),
                            child: BlueTagWidget(
                              content: status,
                            ),
                          )
                      ],
                    ),
                  ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 20),
            constraints: BoxConstraints(
              maxWidth: getDp(120),
            ),
            child: Text(
              amount,
              style: TextStyle(
                color: aceBlackColor,
                fontSize: getSp(16),
                fontWeight: FontWeight.w400,
                height: 14 / 16,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
